#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;


template <typename Container>
void display(const Container &con)
{
    for(auto &elem : con)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

void test()
{
    cout << "sizeof(vector<int>) = " << sizeof(vector<int>) << endl;
    cout << "sizeof(vector<long>) = " << sizeof(vector<long>) << endl;

    vector<int> number = {1, 3, 5, 7, 9, 8, 6, 4, 2, 10};
    display(number);

    cout << endl << "在vector的尾部进行插入与删除" << endl;
    number.push_back(100);
    number.push_back(200);
    display(number);
    number.pop_back();
    display(number);

    //为何vector不提供在头部进行插入与删除的操作呢？
    //因为vector是一端开口的，如果在头部插入一个元素或者删除一个
    //元素，后面的元素都会移动，导致效率比较低，O(N)
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

